AccountBalancesByAsOfDates

data class AccountBalancesByAsOfDates(val accounts: Set<Account>, val asOfDates: IntArray? = null, val balanceType: Account.BalanceType? = null, val outOfDateNull: Boolean = false)

Data storage class to hold account balances (either by as-of dates or for current/future balances) (within TotalAmount objects). When supplied, the order of the list of asOfDates is always preserved.

The instance will be pre-initialized with all accounts, and depending on outOfDateNull all balances will either be preset to null or a TotalAmount object holding zero. It is the responsibility of any code that instantiates this class to properly populate all balances.

Note: The NetWorthCalculator does not enable outOfDateNull and it's guaranteed that as-of balance(s) (TotalAmount objects) will be initialized and never null.

Since

MD2027

Constructors

Link copied to clipboard
constructor(accounts: Set<Account>, asOfDates: IntArray? = null, balanceType: Account.BalanceType? = null, outOfDateNull: Boolean = false)

Create empty data storage instance to hold account balances by as-of dates.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Set of accounts required.

Link copied to clipboard

List of as-of dates required, or null if holding current/future balances (or use balanceType parameter). (note: whilst not recommended, this function can tolerate duplicate as of dates).

Link copied to clipboard

The balance type to obtain balances for when not using as-of dates (i.e. today/future balance) (or use asOfDates parameter).

Link copied to clipboard

Provides the minimum and maximum dates from transaction and account start dates used within this networth calculation. Will return null when the calculation has not yet executed, or when calculating the current/future balance as-of today (i.e. as-of null) Typically useful when graphing balances over time

Link copied to clipboard

When true, null values will be returned (instead of zero) if an account did not exist on a specific as-of date.

Functions

Link copied to clipboard
fun addAccountBalance(account: Account, amtLong: Long, recordDate: Int? = null)

Add an amount to an account's balance when using current/future (no as-of date), or with a single as-of date

fun addAccountBalance(account: Account, asOfDate: Int?, amtLong: Long, recordDate: Int? = null)

Add an amount to a balance for a given account and as-of date (also initialize the as-of date balance if required)

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Return the min/max DateRange for a single account (or null if none recorded) - @since MD2027

Link copied to clipboard

Return a map of all accounts (within this object) => their min/max DateRange - @since MD2027

Link copied to clipboard

Retrieves an account's balance (TotalAmount object) (when using current/future (no as-of date), or with a single as-of date) in the account's own currency. Will return null if the account requested is not present Can return null when outOfDateNull is enabled and where the account did not exist on the as-of date specified

fun getBalance(account: Account, asOfDate: Int?): TotalAmount?

Retrieves an account's balance (TotalAmount object) for the given as-of date, in the account's own currency. Will return null if the account / as-of date requested is not present Can return null when outOfDateNull is enabled and where the account did not exist on the as-of date specified

Link copied to clipboard

Retrieves an unmodifiable list of all balances (TotalAmount objects) for a given account, for all as-of dates (will return null if the account is not present). Individual balances will be in the account's local currency, and can be null when outOfDateNull is enabled and where the account did not exist on the as-of date specified.

fun getBalances(account: Account, targetCurrency: CurrencyType): List<TotalAmount?>?

Retrieves an unmodifiable list of all balances (TotalAmount objects) for a given account, for all as-of dates (will return null if the account is not present). The balances will be converted from the account's currency to the targetCurrency (using the rate on each balance's as-of date). When asOfDates is null (for today/future balance) then the current rate is used. Individual balances can be null when outOfDateNull is enabled and where the account did not exist on the as-of date specified

Link copied to clipboard

Totals up all the balances, over all the accounts (when using current/future (no as-of date), or with a single as-of date), and returns a TotalAmount object containing the balance in the requested currency. Will return null if the as-of date is not present Can return null when using outOfDateNull and where none of the accounts existed on the as-of date

fun getTotalBalance(currency: CurrencyType, asOfDate: Int?): TotalAmount?

Totals up all the balances, over all the accounts, for the given as-of date, and returns a TotalAmount object containing the balance in the requested currency. Will return null if the as-of date is not present Can return null when using outOfDateNull and where none of the accounts existed on the as-of date

Link copied to clipboard

Totals balances by as-of date (or the single current/future balance) across all accounts, returning an unmodifiable list of balances (TotalAmount objects) by as-of date. If only current/future balance is being calculated (with no as-of dates) then a single entry will be returned in the list representing this balance. The (as-of date) order and size of the list are both guaranteed to match the original list of dates specified. Individual as-of date balance entries can be null only when using outOfDateNull and where none of the accounts existed on the specific as-of date

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun setMinMaxDates(date: Int?, account: Account? = null)

Updates the min/max date fields - can be called whenever an account start date or transaction is included within the net worth calculation